"use strict";
{
    class Queue {
        constructor() {
            this.dataStore = [];
        }
        get length() {
            return this.dataStore.length;
        }
        enqueus(element) {
            this.dataStore.push(element);
        }
        dequeus() {
            let priority = this.dataStore[0].code;
            let flag = false;
            for (let i = 1; i < this.dataStore.length; i++) {
                if (this.dataStore[i].code < priority) {
                    flag = true;
                    priority = i;
                }
            }
            return flag
                ? this.dataStore.splice(priority, 1)[0]
                : this.dataStore.shift();
        }
        front() {
            return this.dataStore[0];
        }
        back() {
            return this.dataStore[this.length - 1];
        }
        toString() {
            return this.dataStore
                .map((item) => item.data + "--" + item.code)
                .join("\n");
        }
        clear() {
            this.dataStore.length = 0;
        }
        isEmpty() {
            return this.length === 0;
        }
    }
    let que = new Queue();
    /**
     * 优先级一到5 1的最高 5最低
     */
    que.enqueus({ data: "吃饭", code: 2 });
    que.enqueus({ data: "睡觉", code: 2 });
    que.enqueus({ data: "打豆豆", code: 2 });
    que.enqueus({ data: "学习", code: 1 });
    console.log(que.dequeus());
    console.log(que.dequeus());
    console.log(que.toString());
}
